package com.xhwl.logistics.controller.logistics;


import com.xhwl.common.pojo.ResultJson;
import com.xhwl.logistics.logistics.request.ApprovalProcessParam;
import com.xhwl.logistics.logistics.request.DeleteAprovalParam;
import com.xhwl.logistics.query.ApprovalQuery;
import com.xhwl.logistics.service.logistics.IApprovalProcessService;
import com.xhwl.logistics.vo.logistics.approval.ApprovalProcessVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 审批流程表 前端控制器
 * </p>
 *
 * @author lin.yang
 * @since 2023-12-26
 */
@Slf4j
@Api(tags = "物流审批")
@RestController
@RequestMapping("/approval-process")
public class ApprovalProcessController {


    @Autowired
    private IApprovalProcessService approvalProcessService;


    @PostMapping(value = "saveOrUpdateApproval")
    @ApiOperation(value = "保存物流审批")
    @Transactional
    public ResultJson saveOrUpdateApproval(@RequestBody ApprovalProcessParam param){
        log.info("saveOrUpdateApproval() called with parameters => 【param = {}】",param);
        return approvalProcessService.saveOrUpdateApprovalInfo(param);
    }

    @ApiOperation(value = "详情查询物流审批流程信息,默认只获取有效的流程信息 logicDel='0'")
    @PostMapping(value = "detailApprovalInfo")
    public ResultJson<ApprovalProcessVO> detailApprovalInfo(@RequestBody ApprovalQuery query){
        log.info("detailApprovalInfo() called with parameters => 【query = {}】",query);
        return this.approvalProcessService.detailApprovalInfo(query);
    }


    @PostMapping(value = "deleteApprovalNode")
    @ApiOperation(value = "删除指定流程下的指定节点")
    @Transactional
    public ResultJson deleteApprovalNode(@RequestBody DeleteAprovalParam param){
        log.info("deleteApprovalNode() called with parameters => 【param = {}】",param);
        return this.approvalProcessService.deleteApprovalNode(param);
    }

    @PostMapping(value = "listApprovalProcess")
    @ApiOperation(value = "获取流程信息列表")
    public ResultJson listApprovalProcess(@RequestBody ApprovalQuery approvalQuery){
        log.info("pageApprovalProcess() called with parameters => 【approvalQuery = {}】",approvalQuery);
        return this.approvalProcessService.listApprovalProcess(approvalQuery);
    }

}
